doctype html
html(lang='en')
  head
    meta(charset='UTF-8')
    meta(http-equiv='Content-Type', content='text/html; charset=UTF-8')
    meta(name='renderer', content='webkit')
    title 登录
    link(rel='stylesheet', href='/css/base/ck_base.css', media='screen')
    link(rel='stylesheet', href='/css/login.css', media='screen')
    script(src='/js/jquery-1.8.0.min.js')
    script(src='/js/jquery.common.js')
    script(src='/js/user/util.js')
  body
    .header
      h1.hdLogo
        img(src='/images/lan.png')
      a.hdIntro(href='#') 用户登录
    .content
      .contentMiddle
        .loginView
          .loginTitle
          .loginInputView
            .inputPic.username
            input.loginInput#loginUser(placeholder='请输入用户名/手机号码')
          .loginInputView
            .inputPic.password
            input.loginInput#loginPassword(placeholder='请输入密码',type='password')
          .inputButton#saveBtn 登    录
          //.loginRadioView
            .fl
              input(type='checkbox')
              | 记住密码
            .fr 忘记密码
          a.register(href='/register')
            u 点我注册，马上开始学习
    script(type='text/javascript').
      var link = '#{link}';
      var marginFix = (document.body.clientWidth - 1190) / 2;
      $(".loginView").css("right", marginFix + 50 + "px")
      function placeholderSupport() {
      return 'placeholder' in document.createElement('input');
      }
      if (!placeholderSupport()) {   // 判断浏览器是否支持 placeholder
      $('[placeholder]').focus(function () {
      var input = $(this);
      if (input.val() == input.attr('placeholder')) {
      input.val('');
      input.removeClass('placeholder');
      }
      }).blur(function () {
      var input = $(this);
      if (input.val() == '' || input.val() == input.attr('placeholder')) {
      input.addClass('placeholder');
      input.val(input.attr('placeholder'));
      }
      }).blur();
      }
      ;
      $(function() {
      $("#saveBtn").click(function() {
      var loginUser = $("#loginUser").val();
      var loginPassword = $("#loginPassword").val();
      console.log(loginUser,loginPassword);
      if (loginUser == '') {
      $.alertBoxy({ message: '请输入用户名！' });
      return;
      }
      if (loginPassword == '') {
      $.alertBoxy({ message: '请输入密码！' });
      return;
      }
      var params = [
      "username=" + encodeURIComponent(loginUser),
      "&password=" + encodeURIComponent(loginPassword),
      "&link=" + encodeURIComponent(link)
      ].join('');
      var tipboxy = false;
      $.ajax({
      url: "/login",
      type: "post",
      data: params,
      dataType: "json",
      async: false,
      beforeSend: function() {
      tipboxy = $.tipsBoxy({ type: "loading", message: "数据提交中...", mask: true });
      },
      success: function(ret) {
      tipboxy.cancel();
      if (ret.code == 0) {
      window.location.href=ret.link;
      } else {
      $.alertBoxy({ message: ret.result });
      }
      }
      });      
      });
      });
